/*
 * Amkai Enterprise (AE) 
 * Copyright 2004-2006 by Amkai(TM), Inc.
 * www.amkai.com
 * 
 * Project: webservice
 * Package: com.amkai.aes.webservice.binary.objecthandler.locking
 * File: LockJobHandler.java
 * Created: Jan 24, 2011 4:14:17 PM
 * Author: Miskolczi Peter 
 * 
 */
package com.amkai.aes.webservice.binary.objecthandler.locking;

import java.io.Serializable;

import com.amkai.aes.aescommon.locking.LockInfo;
import com.amkai.aes.aescommon.service.binary.job.locking.LockJob;
import com.amkai.aes.server.locking.LockManager;
import com.amkai.aes.webservice.binary.JobObjectHandler;

/**
 * LockJobHandler
 * @author Miskolczi Peter
 * Description:
 *
 */
public class LockJobHandler implements JobObjectHandler<LockJob, Serializable, LockInfo> {

	@Override
	public LockInfo process(LockJob job, Serializable object) throws Exception {
		LockInfo result = null;
		switch (job.lockKind) {
		case GET:
			result = LockManager.instance.getLock(job.lockId);
			break;
			
		case CHECK:
			result = LockManager.instance.checkLock(job.lockId);
			break;
				
		case RELEASE:
			result = LockManager.instance.releaseLock(job.lockId);
			break;
		}
		return result;
	}

}
